<template>
  <div class="my-wbox">
    <div class="my-workbench-top">
      <h3>宁乡市行政区域图</h3>
      <span>数据截止时间：{{ timeEnd }} 24：00</span>
    </div>
    <div class="my-workbench-detail">
      <div class="my-workbench-detail__box">
        <h3>{{ townName }}入户进度</h3>
        <div class="my-workbench-detail__box__info">
          <OneEchart :resize="resize"></OneEchart>
        </div>
      </div>
      <div class="my-workbench-detail__box">
        <h3>{{ townName }}每天入户趋势图</h3>
        <div class="my-workbench-detail__box__info">
          <TwoEchart :resize="resize"></TwoEchart>
        </div>
      </div>
      <div class="my-workbench-detail__box">
        <h3>{{ townName }}每个村/社区上报户数统计图</h3>
        <div class="my-workbench-detail__box__info">
          <ThreeEchart :resize="resize"></ThreeEchart>
        </div>
      </div>
      <div class="my-workbench-detail__box">
        <h3>{{ townName }}疫苗接种情况分析图</h3>
        <div class="my-workbench-detail__box__info">
          <FourEchart :resize="resize"></FourEchart>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang='ts'>
import { ref, onMounted, watch, onBeforeUnmount } from 'vue'
import { useRoute } from 'vue-router'
import OneEchart from '@/views/workbench/components/OneEchart.vue'
import TwoEchart from '@/views/workbench/components/TwoEchart.vue'
import ThreeEchart from '@/views/workbench/components/ThreeEchart.vue'
import FourEchart from '@/views/workbench/components/FourEchart.vue'
import { FunTime } from '@/global/methods'
const route = useRoute()
const townName = route.query.townName as string
onMounted(() => {
  window.addEventListener('resize', onResize)
})
//前一天
const timeEnd = FunTime(new Date().getTime() - 24 * 60 * 60 * 1000)
//浏览器变化
const resize = ref<boolean>(false)
const onResize = () => {
  resize.value = !resize.value
}
//注销之前
onBeforeUnmount(() => {
  window.removeEventListener('resize', onResize)
})
</script>
<style scoped lang='scss'>
.my-wbox{height: 100%;}
.my-workbench-detail {
  width: 100%;
  height: calc(100% - 30px);
  overflow: hidden;

  &__box {
    float: left;
    width: calc(50% - 20px);
    height: calc(50% - 10px);
    border: 1px solid $my-color-border;
    box-sizing: border-box;
    padding: 10px;
    box-sizing: border-box;

    >h3 {
      font-size: 14px;
      color: #333;
      font-weight: bold;
      line-height: 20px;
      text-align: center;
    }

    &__info {
      width: 100%;
      height: calc(100% - 20px);
    }

    &:nth-child(2n) {
      margin-left: 20px;
    }

    &:nth-child(1),
    &:nth-child(2) {
      margin-bottom: 20px;
    }
  }
}

.my-workbench-top {
  display: flex;
  line-height: 30px;
  font-size: 14px;
  color: #333;
  >h3 {
    flex: 1;
    font-size: 14px;
    font-weight: bold;
  }
}
</style>